﻿CREATE PROCEDURE [dbo].[DeleteLogDelete]
(
	@Original_Id int,
	@Original_MD datetime
)
AS
DECLARE @strMsg nvarchar(500), @intRet int, @intErrCode int
	SET NOCOUNT ON;

SELECT @intRet = Id
FROM [PR].[DeleteLog] WHERE Id = @Original_Id AND MD = @Original_MD
IF (@@rowcount <> 1)
BEGIN
	SELECT @intErrCode = 1, 
	@strMsg = 'Данные изменены после последнего запроса!'
	RAISERROR (@strMsg, 11, 1)
	RETURN @intErrCode
END

	SET NOCOUNT OFF;

DELETE FROM [PR].[DeleteLog] WHERE Id = @Original_Id

RETURN 0
